#!/bin/zsh

# 私有库名称
#PODNAME=${PWD##*/}
PODNAME="LBHeaderExpandLib"

function obtain_git_tag
{
  # 类似 "s.version    = '0.0.1'"
  VERSION_STRING=`grep -E 's.version.*=' ${PODNAME}.podspec`
  TAG=`tr -cd "[0-9.]" <<< "$VERSION_STRING"`
  TAG=${TAG#*${TAG:0:1}}
  echo ${TAG}
}
# 当前tag
TAG=`obtain_git_tag`
echo "准备发版的版本号：$TAG"
if [ "$TAG" = "" ]; then
   echo "match tag failed"
   exit 1
fi

function judgeResult()
{
	result=$1
	if [ result != 0 ];then
		exit $result
	fi
}


git add .

git commit -m "${PODNAME} ${TAG}"

git push origin

git tag  $TAG || judgeResult $?

git push origin --tags || judgeResult $?
